const $ = window.$ = window.Dom7

/**
 * ajax封装fetch
 *
 * @return {Promise}
 */
$.fetch = function (api, data = {}) {
  let url =  `http://hongezi.cn:1919/${api}`;
  if (['beau', 'find'].indexOf(api) != -1) {
    url = `http://hongezi.cn/${api}/${api}.json`
  }
  return new Promise(function (resolve, reject) {
    $.ajax({
      url,
      data,
      crossDomain: true,
      method: 'POST',
      dataType: 'json',
      success: resolve, // data, status, xhr
      error: reject, // xhr, status
      // complete: reject,
    })
  })
}
